package com.bua.datafactory;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.bua.dao.DesignItem;

public class OrderDetailDataFactory extends DataFactory {

    public String orderId;
    public String createdDate;
    public String patientName;
    public String patientSex;
    public String patientAge;
    public String patientPhone;
    public String dentistName;
    public String dentistPhone;
    public String weituoDate;
    public String daiyaDate;
    public DesignItem[] designItem;


    public OrderDetailDataFactory(String jsonString) {
        super(jsonString);
        if (status == 200) {
            try {
                JSONObject order= body.getJSONObject("order") ;
                orderId = order.getString("id");
                createdDate = order.getString("created");
                patientName = order.getString("PatientName");
                patientSex = order.getString("Sex");
                patientAge = order.getString("Age");
                patientPhone = order.getString("PatientPhone");
                dentistName = order.getString("DentistName");
                dentistPhone = order.getString("DentistPhone");
                weituoDate = order.getString("assembleTime");
                daiyaDate = order.getString("confirmTime");
                JSONArray jsDesignList = body.getJSONArray("designList");
                int size = jsDesignList.length();
                designItem = new DesignItem[size];
                for (int index = 0; index < jsDesignList.length(); index++) {
                    JSONObject jDesignItem = jsDesignList.getJSONObject(index);
                    designItem[index]=new DesignItem();
                    designItem[index].designId = jDesignItem.getString("id");
                    designItem[index].designImage = jDesignItem.getString("designImg");
                    designItem[index].approveStatus = jDesignItem.getString("designStatus");
                    designItem[index].designType = jDesignItem.getString("designCategory");
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
